package online.misscl.lsy.controller.front;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import online.misscl.lsy.controller.BaseController;
import online.misscl.lsy.entity.dto.GetConsultationAnnouncementDTO;
import online.misscl.lsy.entity.dto.vo.ConsultationAnnouncementVo;
import online.misscl.lsy.entity.dto.vo.TableDataInfoVo;
import online.misscl.lsy.service.ConsultationAnnouncementService;
import online.misscl.lsy.util.PageUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 咨询公告表 前端控制器
 * </p>
 *
 * @author misscl
 * @since 2023/03/11 11:14
 */
@RestController
@RequestMapping("/front/consultationAnnouncement")
@Api(tags = "咨询公告模块")
public class ConsultationAnnouncementController extends BaseController {

    @Autowired
    private ConsultationAnnouncementService consultationAnnouncementService;

    @ApiOperation(value = "查询咨询公告",notes = "type = 0 咨询，1 公告")
    @GetMapping("/getConsultationAnnouncement")
    public TableDataInfoVo<List<ConsultationAnnouncementVo>> getConsultationAnnouncement(GetConsultationAnnouncementDTO getConsultationAnnouncementDTO) {
        PageHelper.startPage(getConsultationAnnouncementDTO.getPageNum(),getConsultationAnnouncementDTO.getPageSize());
        List<ConsultationAnnouncementVo> list = consultationAnnouncementService.getConsultationAnnouncement(getConsultationAnnouncementDTO.getType());
        PageInfo<ConsultationAnnouncementVo> page = new PageInfo<>(list);
        return getDataTable(page.getList(),page.getTotal());


    }
}
